package btp.Trigonometry;

import btp.Time.Time;

public class Angle {
	int degrees;
	int minutes;
	double seconds;
	public static final double convert = Math.PI/180;
	
	public Angle(int degrees, int minutes, double seconds) {
		this.degrees = degrees;
		this.minutes = minutes;
		this.seconds = seconds;
	}
	
	public double toDouble(){
		return degrees+minutes/60.0+seconds/3600.0;
	}
	
	public static Angle fromDouble(double d){
		int degrees = (int) Math.floor(d);
		d = (d-degrees)*60;
		int minutes = (int) Math.floor(d);
		d = (d-degrees)*60;
		return new Angle(degrees, minutes, d);
	}
	
	public double toRadians(){
		return toDouble()*convert;
	}
	
	public static Angle getFromRadians(double d){
		return fromDouble(d/convert);
	}
	
	public Time toTime(){
		int secs = (int) Math.round((degrees*3600+minutes*60+seconds)/15);
		int rd=0;
		if(secs<0)
		{
			rd--;
			secs+=86400;
		}
		int mins = secs/60;
		secs%= 60;
		int hours = mins/60;
		mins%= 60;
		
		return new Time(hours, mins, secs, (long) rd);	
	}
	
	public static Angle fromTime(Time t){
		//To be implemented.
		return null;
	}
}
